﻿<%@ Page Language="C#" MasterPageFile="~/Templates/MasterpageAdmin.Master" AutoEventWireup="true" Inherits="QuanCafe.Admin.News" ValidateRequest="false" enableEventValidation="false"%>
<%@ Register assembly="FredCK.FCKeditorV2" namespace="FredCK.FCKeditorV2" tagprefix="FCKeditorV2" %>
<%@ Import Namespace ="QuanCafe.DataLayer"%>
<%@ Import Namespace ="System.Data" %>
<%@ Import Namespace ="System.Data.SqlClient" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>DANH SÁCH TIN TỨC</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <!-- content-box-header --> 		
    <div class="content-box-header">					
        <h3>DANH SÁCH TIN TỨC</h3>								
    </div> 
    <!-- End .content-box-header -->  
    <div class="content-box-content">
        <div class="notification attention png_bg" id="error_pnl" style="float: left;">
			<div>
                <asp:Label ID="lblError" runat="server" CssClass="label_error"></asp:Label>
                <asp:TextBox ID="txtNewID" runat="server" Visible="false"></asp:TextBox>
                <asp:TextBox ID="txtImageName" runat="server" Visible="False"></asp:TextBox>
			</div>
		</div>
        <div class="content-box-row">
            <fieldset>                
                <div>
                    <div class="left required" style="width: 70%;">
                        <span>Tiêu đề:</span>
                        <asp:TextBox ID="txtTitle" runat="server" CssClass="text-input" Width="80%"></asp:TextBox>
                    </div>            
                </div>
                <div>
                    <div class="left required" style="width: 70%">
                        <span>Tóm tắt:</span>
                        <asp:TextBox ID="txtDescription" runat="server" CssClass="text-input" TextMode="MultiLine" Width="80%" Rows="5"></asp:TextBox>
                    </div>
                    <div class="right" style="width: 20%">
                        <asp:Image ID="imgBox" runat="server" BorderColor="#999999" BorderWidth="1px" Height="130px" ImageUrl="~/images/Icons/NoImage.JPG" Width="130px" />
                    </div>
                </div>
                <div>
                    <div class="left" style="width: 100%;">
                        <span>Ảnh nếu có</span>
                        <asp:FileUpload ID="txtFileImageUpLoad" runat="server" CssClass="text-input" style="width:40%" />
                        <asp:Button ID="btnChangePicture" runat="server" Text="Đổi hình" Visible="False" Width="152px" onclick="btnChangePicture_Click" />
                    </div>
                </div>
                <div>
                    <div class="left" style="width: 70%;">
                        <span>Tags</span>
                        <asp:TextBox ID="txtTags" runat="server" CssClass="text-input" Width="80%" ToolTip='Các tag cách nhau bằng dấu phẩy "," '></asp:TextBox>
                    </div>
                    <div class="left" style="width: 20%;">
                        <span style="width: auto;">Tin đặc biệt :</span>
                        <asp:CheckBox ID="chk" runat="server" />
                    </div>
                </div>
                <div>
                    <div class="left" style="width: 100%;">
                        <span style="margin-bottom: 10px;">Nội dung:</span>
                        <FCKeditorV2:FCKeditor ID="edtContent" Height="400px" Width="95%" runat="server" ToolbarSet="Default"></FCKeditorV2:FCKeditor>
                    </div>
                 </div>           
            </fieldset>
        </div>
        <div class="content-box-row">
            <div class="button-row">
                <center>
                   <asp:Button ID="btnAddNew" runat="server" Text="Hũy bỏ" CssClass="button" 
                        onclick="btnAddNew_Click" />
                    <asp:Button ID="btnSave" runat="server" Text="Lưu" CssClass="button" OnClientClick="javascript: return CheckForm($('.label_error:eq(0)'))"
                        onclick="btnSave_Click" />
                    <asp:Button ID="btnDelete" runat="server" OnClientClick="javascript:return confirm('Có thật sự muốn xóa các tin này không?')" Text="Xóa" CssClass="button" 
                        onclick="btnDelete_Click" />
                </center>
            </div>
        </div>
        <div class="notification information png_bg" id="notice_pnl" style="float: left;">
            <div>
                <asp:Label ID="lblNotice" runat="server"></asp:Label>
            </div>
        </div>
        <div class="content-box-row">
            <span style="margin-right: 14px;">Xem số lượng</span>
            <asp:TextBox ID="txtViewQuantity" runat="server" CssClass="text-input number-input"
                Width="40px" Text="0"></asp:TextBox>
            <span style="margin:0 14px 0 14px;">trên tổng số</span>
            <asp:TextBox ID="txtTotal" runat="server" CssClass="text-input number-input" Width="40px"
                ReadOnly="true"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;
            <asp:Button ID="btnView" runat="server" OnClick="btnView_Click" Text="Xem" OnClientClick="javascript:return CheckForm($('.label_error:eq(0)'))" />
            <asp:Button ID="btnViewAll" runat="server" OnClick="btnViewAll_Click" Text="Xem tất cả" />
        </div>
        <div class="content-box-row">
            <asp:DataGrid CssClass="grid" ID="dtgNew" Width="100%" 
                runat="server" AllowPaging="True" PageSize="20"
                AutoGenerateColumns="False" PagerStyle-Mode="NumericPages" 
                onitemcommand="dtgNew_ItemCommand" 
                onpageindexchanged="dtgNew_PageIndexChanged" CaptionAlign="Bottom">
                <PagerStyle Mode="NumericPages" CssClass="gridPage"></PagerStyle>
                <HeaderStyle CssClass="gridHeader" />
                <FooterStyle CssClass="gridFooter" />
                <AlternatingItemStyle CssClass="gridAlter" />
                <ItemStyle CssClass="gridItem" />
                <Columns>
                    <asp:BoundColumn DataField="NewsID" Visible="false"></asp:BoundColumn>    
                    <asp:TemplateColumn HeaderText="STT">
                        <HeaderStyle Width="5%" />
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                        <ItemTemplate>
                            <asp:LinkButton Runat="server" ID="btnID" CommandName="Edit">
                                <%# Container.ItemIndex + 1 + dtgNew.PageSize * dtgNew.CurrentPageIndex%>
                            </asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateColumn>                
                    <asp:TemplateColumn HeaderText="Tiêu đề">
                        <HeaderStyle Width="20%" />
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:LinkButton Runat="server" ID="btnName" CommandName="Edit">
                                <%# DataBinder.Eval(Container, "DataItem.Title")%>
                            </asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateColumn>            
                    <asp:TemplateColumn HeaderText="Miêu tả ngắn">
				        <HeaderStyle Width="35%"></HeaderStyle>
					    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
					    <ItemTemplate>
					        <%# DataBinder.Eval(Container, "DataItem.strSpecialNews")%>
					        <%# DataBinder.Eval(Container, "DataItem.Description")%>
					    </ItemTemplate>
				    </asp:TemplateColumn>                
                    <asp:TemplateColumn HeaderText="Ngày đăng">
				        <HeaderStyle Width="5%"></HeaderStyle>
					    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
					    <ItemTemplate>
					        <%# DataBinder.Eval(Container, "DataItem.PostDate")%>
					    </ItemTemplate>
				    </asp:TemplateColumn>                        
                    <asp:TemplateColumn HeaderText="Người đăng">
			            <HeaderStyle Width="10%"></HeaderStyle>
				        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
				        <ItemTemplate>
					        <%# DataBinder.Eval(Container, "DataItem.Creator")%>
					    </ItemTemplate>
				    </asp:TemplateColumn>                
                    <asp:TemplateColumn HeaderText="Kích hoạt">
                        <HeaderStyle Width="10%"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:ImageButton ID="btnActive" runat="server" Width="15px" Height="15px"
                                CommandArgument='<%# Eval("NewsID") %>' CommandName="activechange"   ImageUrl="~/images/icons/btnOK.jpg" />                
                        </ItemTemplate>
                    </asp:TemplateColumn>                
                    <asp:TemplateColumn HeaderText="&nbsp;">
                        <HeaderStyle Width="10%"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:ImageButton ID="btnUpRank" runat="server" Width="20px" Height="20px" CommandName="up" ImageUrl="~/images/up-icon.png" />
                            &nbsp;&nbsp;
                            <asp:ImageButton ID="btnDownRank" runat="server" Width="20px" Height="20px" CommandName="down" ImageUrl="~/images/down-icon.png" />
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="Chọn">
	                    <HeaderStyle Width="5%" HorizontalAlign="Center"></HeaderStyle>
	                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
	                    <HeaderTemplate>
	                        <input type="checkbox" id="chkSelectAll" onclick="CheckAll($(this), '<%= dtgNew.ClientID %>')" />
	                    </HeaderTemplate>
	                    <ItemTemplate>
	                        <span id='<%# DataBinder.Eval(Container, "DataItem.NewsID")%>'></span>
		                    <asp:CheckBox id="chkSelect" runat="server"></asp:CheckBox>
	                    </ItemTemplate> 
                    </asp:TemplateColumn>
                </Columns>
            </asp:DataGrid>
        </div>
    </div>
    <script type="text/javascript" language="javascript">
        if($.trim( $("#<%= this.lblError.ClientID %>").html() ) == "") $("#error_pnl").hide();
        if($.trim( $("#<%= this.lblNotice.ClientID %>").html() ) == "") $("#notice_pnl").hide();
    </script> 
    <script type="text/javascript" language="javascript">
        function CheckAll(obj, gridID)
        {
            var list_cate = $("#" + gridID);
            var isChecked = obj.is(":checked");
            var checkbox_list = $(":checkbox:[id != 'chkSelectAll']", list_cate);
            
            for(var i=0 ; i < checkbox_list.length ; i++)
            {
                checkbox_list.get(i).checked = isChecked;
            }
        }        
    </script>
</asp:Content>
